package net.lzzy.practices.repositories;

import net.lzzy.practices.entities.Result;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.UUID;

/**
 * @author 渊何
 */
public interface ResultRepository extends JpaRepository<Result, UUID> {
    List<Result> findResultsByQuestionId(UUID questionId);
    @Query("select  r from Result r where r.student.id = :sid and  r.question.id in :ids order by r.question.ordinal")
    List<Result> findResultsByQuestions(@Param("sid") UUID studentId,  @Param("ids") List<UUID> questionIds);
    List<Result> findResultsByStudentIdAndQuestionId(UUID studentId, UUID questionId);
    @Query("select  r from Result r where r.student.id  in :ids")
    List<Result> findResultsByQuestions(@Param("ids") List<UUID> questionIds);
}
